<table class="edits-table">
  <tr>
    <% if type == 'User' %>
      <th>Entry</th>
    <% else %>
      <th>User</th>
    <% end %>
    <th>Edited</th>
    <th>Edited On</th>
    <th>Reason</th>
    <th>Moderated On</th>
    <th>Comment</th>
    <th>Approved</th>
  </tr>

<% item.edits.each do |edit| %>
  <tr>
    <td>
      <% if type == 'User' %>
        <% if edit.item.nil? %>
          deleted_entry
        <% else %>
          <%= link_to edit.item.to_s, edit.item %>
        <% end %>
      <% else %>
        <%= link_to edit.user.username, edit.user %>
      <% end %>
    </td>
    <td>
    <% edit.change.each_pair do |key, value|  %>

      <% if value.last.blank? %>
        Cleared <strong style="color: blue"><%=h key %></strong>

      <% elsif key == "created" %>
        Created entry for 
        <strong style="color:green"><%=h value.first %></strong>

      <% elsif key == "linked genre" %>
        Linked genre <strong style="color:green"><%=h value.first %></strong>
 
      <% elsif key == "unlinked genre" %>
        Unlinked genre <strong style="color:green"><%=h value.first %></strong>

      <% elsif key == "delete" %>
        Delete entry for <strong style="color:red"><%=h value.first %></strong>
   
      <% elsif key == "Added" %>
        Added <strong style="color:green"><%=h value.last %></strong> to 
        <strong style="color:green"><%=h value.first %></strong>

      <% elsif key == "Removed" %>
        Removed <strong style="color:red"><%=h value.last %></strong> from 
        <strong style="color:red"><%=h value.first %></strong>

      <% elsif key == "added image" %>
        Added image <strong style="color:green"><%=h value.first %></strong>

      <% else %>
        Changed <strong style="color: blue"><%=h key %></strong> from  
        <strong style="color: red"><%=h value.first %></strong> to 
        <strong style="color: green"><%=h value.last %></strong>
      <% end %>

      <br />
    <% end %>
    </td>
    <td><%= edit.created_at.strftime('%d-%m-%y') %></td>
    <td><%= edit.reason %></td>
    <td><%= edit.updated_at.strftime('%d-%m-%y') unless edit.updated_at == edit.created_at %></td>
    <td><%= edit.comment %></td>
    <td><%= edit.approved %></td>
  </tr>  
<% end %>

</table>
